package com.zzedu.web.controller;

import com.zzedu.common.annotation.Log;
import com.zzedu.common.enums.BusinessType;
import com.zzedu.common.enums.OperatorType;
import com.zzedu.domain.ZzCourse;
import com.zzedu.manager.IZzPictureBookManager;
import com.zzedu.result.Result;
import com.zzedu.stu.req.QueryAllZzPictureNode;
import com.zzedu.stu.req.QueryPageZzPictureBook;
import com.zzedu.stu.req.QueryPictureByNodeContent;
import com.zzedu.stu.req.QueryUnitList;
import com.zzedu.stu.rsp.ApiZzPictureBookNodeVO;
import com.zzedu.stu.rsp.ApiZzPictureBookVO;
import com.zzedu.stu.rsp.ApiZzPictureContentVO;
import com.zzedu.utils.BaseReq;
import com.zzedu.utils.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 绘本
 */
@RestController
@RequestMapping("pictureBook")
public class PictureBookController {

    @Autowired
    IZzPictureBookManager pictureBookManager;


    /**
     * 绘本-unitList-新版
     *
     * @param req
     * @return
     */
    @PostMapping(value = {"/unitList"}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE})
    @Log(title = "绘本-unitList", businessType = BusinessType.APP_STUDENT, operatorType = OperatorType.MOBILE)
    public Result<List<ZzCourse>> courseListNews(@Validated @RequestBody BaseReq<QueryUnitList> req) {
        return pictureBookManager.courseListNews(req.getData());
    }

    /**
     * 绘本列表-新版
     *
     * @param req
     * @return
     */
    @PostMapping(value = {"/queryPage"}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE})
    @Log(title = "绘本-列表", businessType = BusinessType.APP_STUDENT, operatorType = OperatorType.MOBILE)
    public Result<PageData<ApiZzPictureBookVO>> queryPageNews(@Validated @RequestBody BaseReq<QueryPageZzPictureBook> req) {
        return pictureBookManager.queryPageNews(req.getData());
    }

    /**
     * 绘本节点
     *
     * @param req
     * @return
     */
    @PostMapping(value = {"/queryAllNode"}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE})
    @Log(title = "绘本-绘本节点", businessType = BusinessType.APP_STUDENT, operatorType = OperatorType.MOBILE)
    public Result<List<ApiZzPictureBookNodeVO>> queryAllNode(@Validated @RequestBody BaseReq<QueryAllZzPictureNode> req) {
        return pictureBookManager.queryAllNode(req.getData());
    }


    /**
     * DAYS-节点列表
     *
     * @param req
     * @return
     */
    @PostMapping(value = {"/queryDaysNode"}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE})
    @Log(title = "绘本-DAYS-节点列表", businessType = BusinessType.APP_STUDENT, operatorType = OperatorType.MOBILE)
    public Result<List<ApiZzPictureBookNodeVO>> queryDaysNode(@Validated @RequestBody BaseReq<QueryPictureByNodeContent> req) {
        return pictureBookManager.queryDaysNode(req.getData());
    }

    /**
     * 绘本-绘本节点-内容
     *
     *
     * @param req
     * @return 当前绘本，当前节点下 所有题目id列表
     */
    @PostMapping(value = {"/queryPictureByNodeContent"}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE})
    @Log(title = "绘本-绘本节点-内容", businessType = BusinessType.APP_STUDENT, operatorType = OperatorType.MOBILE)
    public Result<List<ApiZzPictureContentVO>> queryPictureByNodeContent(@Validated @RequestBody BaseReq<QueryPictureByNodeContent> req) {
        return pictureBookManager.queryPictureByNodeContent(req.getData());
    }
}
